/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package service;

import java.util.List;
import javax.ejb.Stateful;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import model.Cliente;

/**
 *
 * @author Omar
 */
@Stateful(mappedName="ClienteBean")
public class ClienteFacade implements ClienteFacadeRemote {
    @PersistenceContext(unitName="ClientePU")
    private EntityManager em;

    @Override
    public void create(Cliente cliente) {
       em.persist(cliente);
    }

    @Override
    public void remove(Cliente cliente) {
         em.remove(em.merge(cliente));
    }

    @Override
    public Cliente find(Object id) {
       return em.find(Cliente.class, id);
    }

    @Override
    public List<Cliente> findAll() {
        return em.createQuery("select object(o) from Cliente as o").getResultList();
    }
    
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
    
}
